package com.myComsole.chat.model;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @Date 2025/8/20 18:19
 * @Author huangfaxiang
 */
@Data
public class Message {
    private Author author;
    private Content content;
    public boolean isUserContent(){
        if (author!=null){
            if (StrUtil.equals(author.getRole(),"user")){
                return true;
            }
        }
        return false;
    }

    public String getMsgContent() {
        StringBuilder contentResult = new StringBuilder();
        if (content==null||content.getParts()==null) {
            return "";
        }
        //获取对话内容
        for (String part : content.getParts()) {
            contentResult.append(part);
        }
        return contentResult.toString();
    }
}
